<%@page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Refresh" content="2">
<style type="text/css">
<%@include file="../stylesheets/progresbar.css"%>
 <%@ include file="../stylesheets/main.css"%> 
<%@ include file="../stylesheets/header.css"%>
<%@ include file="../stylesheets/footer.css"%>
 <%@ include file="../stylesheets/indexContent.css"%>
<%@ include file="../stylesheets/carousel.css"%> 
</style>


<script language="JavaScript">

function loadPage(id,list) {
    document.forms['speed'].operation.value='changeSpeed';
    document.forms['speed'].selectedId.value=id;
    document.forms['speed'].speedValue.value=list.options[list.selectedIndex].value;
    document.forms['speed'].submit();
    return false;
	}

function pause(id) {
    document.forms['pauseTheard'].operation.value='pauseTheard';
    document.forms['pauseTheard'].selectedId.value=id;
    document.forms['pauseTheard'].submit();
    return false;
	}
	
function removeTheard(id) {
    document.forms['pauseTheard'].operation.value='removeTheard';
    document.forms['pauseTheard'].selectedId.value=id;
    document.forms['pauseTheard'].submit();
    return false;
	}
	
function addTheard() {
    document.forms['pauseTheard'].operation.value='addTheard';
    document.forms['pauseTheard'].submit();
    return false;
	}
</script>

<title>System Produkcji SZCZEGOLY</title>
</head>
<body>
	<div id="left-column-outer">
		<div id="left-column"></div>
	</div>
	<div id="center-column">
		<div class="CenteredContainer">
			<img id="background_noresize" alt="background_noresize"
				src="<%=request.getContextPath()%>/img/background.jpg" />
			<%@ include file="header.jsp"%>
			<div class="ContentShade">
				<table>
					<tr>
						<th style="width: 120px;">Stan</th>
						<th></th>
						<th>Progres</th>
						<th>Nr. Zamowienia</th>
						<th style="width: 60px;">Nazwa</th>
						<th>Liczba</th>
						<th>Zatrzymaj</th>
						<th>Stan Maszyny</th>
						<th>
							<form name="pauseTheard" action="productiondetails" method="post">
								<INPUT TYPE="BUTTON" value="Dodaj maszyne" ONCLICK="addTheard()">
								<input type="hidden" name="operation"> <input
									type="hidden" name="selectedId">
							</form>
						</th>
					</tr>

					<c:forEach items="${be.productionThreadsList}" var="pt"
						varStatus="loop">
						<tr align="center">
							<c:if test="${pt.pause}">
								<td align="center" style="width: 120px;"><img id="progress"
									src="<%=request.getContextPath()%>/img/production.png" /></td>
								<td>Linia ${pt.number } prace wstrzymane.</td>
								<td><div id="progressbar">
										<progress max="100" value="${pt.procent}" />
									</div>
									<div id="progressnum">${pt.procent} %</div>
									</div></td>
							</c:if>

							<c:if test="${pt.start && !pt.pause}">
								<td align="center"><img id="progress"
									src="<%=request.getContextPath()%>/img/production.gif" /></td>
								<td>Linia ${pt.number } pracuje ${pt.time} s.</td>
								<td><div id="progressbar">
										<progress max="100" value="${pt.procent}" />
									</div>
									<div id="progressnum">${pt.procent} %</div>
									</div></td>
							</c:if>
							<c:if test="${!pt.start}">
								<td align="center"><img id="progress"
									src="<%=request.getContextPath()%>/img/production.png" /></td>
								<td>Linia ${pt.number } oczekuje</td>
								<td>
									<div id="pwidget">
										<div id="progressbar">
											<progress max="100" value="0" />
										</div>
										<div id="progressnum">0 %</div>
									</div>
								</td>
							</c:if>
							<td>${pt.ppr.productionId }</td>
							<td style="width: 60px;">${pt.ppr.name }</td>
							<td>${pt.ppr.quantity}</td>
							<td>
								<form name="pauseTheard" action="productiondetails"
									method="post">
									<INPUT TYPE="BUTTON"
										value=<c:if test="${pt.pause}"> "Wznów"</c:if>
										<c:if test="${!pt.pause}"> "Wstrzymaj"</c:if>
										ONCLICK="pause(${pt.number })"> <input type="hidden"
										name="operation"> <input type="hidden"
										name="selectedId">
								</form>
							</td>
							<td>
								<form name="speed" action="productiondetails" method="post">
									<select name="file"
										onchange="loadPage(${pt.number }, this.form.elements[0])"
										style="background-color: #ffffff">
										<option value=5
											<c:if test="${pt.speed eq 5}"> selected="true"</c:if>>Zły</option>
										<option value=10
											<c:if test="${pt.speed eq 10}"> selected="true"</c:if>>Średni</option>
										<option value=20
											<c:if test="${pt.speed eq 20}"> selected="true"</c:if>>Dobry</option>
									</select> <input type="hidden" name="operation"> <input
										type="hidden" name="selectedId"> <input type="hidden"
										name="speedValue">
								</form>

							</td>
							<td>
								<form name="pauseTheard" action="productiondetails"
									method="post">
									<INPUT TYPE="BUTTON" value="Usuń maszyne"
										ONCLICK="removeTheard(${pt.number })"> <input type="hidden"
										name="operation"> <input type="hidden"
										name="selectedId">
								</form>
							</td>
						</tr>
					</c:forEach>

				</table>









				<%@ include file="footer.jsp"%>
			</div>
		</div>
	</div>
	<div id="right-column-outer">
		<div id="right-column"></div>
	</div>

</body>
</html>